package weibo4j;

import weibo4j.model.PostParameter;
import weibo4j.model.User;
import weibo4j.model.UserWapper;
import weibo4j.model.WeiboException;
import weibo4j.util.WeiboConfig;

public class FriendshipsUtil extends Friendships {
	/**
	 * 
	 * @return list of the user's follow
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/friendships/friends">friendships/friends</a>
	 * @since JDK 1.5
	 */
	public UserWapper getFriendsByScreenName(Weibo weibo, String screen_name, Integer count,
			Integer cursor, Integer trim_status) throws WeiboException {
		return User
				.constructWapperUsers(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "friendships/friends.json",
						new PostParameter[] {
								new PostParameter("screen_name", screen_name),
								new PostParameter("count", count.toString()),
								new PostParameter("cursor", cursor.toString()),
								new PostParameter("trim_status", trim_status
										.toString()) }));
	}

	/**
	 * 
	 * @return list of the user's follow
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/friendships/friends">friendships/friends</a>
	 * @since JDK 1.5
	 */
	public UserWapper getFriendsByID(Weibo weibo, String id, Integer count, Integer cursor,
			Integer trim_status) throws WeiboException {
		return User
				.constructWapperUsers(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "friendships/friends.json",
						new PostParameter[] {
								new PostParameter("uid", id),
								new PostParameter("count", count.toString()),
								new PostParameter("cursor", cursor.toString()),
								new PostParameter("trim_status", trim_status
										.toString()) }));
	}

	/**
	 * @return list of users
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/friendships/followers">friendships/followers</a>
	 * @since JDK 1.5
	 */
	public UserWapper getFollowersByName(Weibo weibo, String screen_name, Integer count,
			Integer cursor, Integer trim_status) throws WeiboException {
		return User
				.constructWapperUsers(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "friendships/followers.json",
						new PostParameter[] {
								new PostParameter("screen_name", screen_name),
								new PostParameter("count", count.toString()),
								new PostParameter("cursor", cursor.toString()),
								new PostParameter("trim_status", trim_status
										.toString()) }));
	}

	/**
	 * @return list of users
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/friendships/followers">friendships/followers</a>
	 * @since JDK 1.5
	 */
	public UserWapper getFollowersById(Weibo weibo, String id, Integer count,
			Integer cursor, Integer trim_status) throws WeiboException {
		return User
				.constructWapperUsers(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "friendships/followers.json",
						new PostParameter[] {
								new PostParameter("uid", id),
								new PostParameter("count", count.toString()),
								new PostParameter("cursor", cursor.toString()),
								new PostParameter("trim_status", trim_status
										.toString()) }));
	}

	/**
	 * @return list of users
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/friendships/followers">friendships/followers</a>
	 * @since JDK 1.5
	 */
	public UserWapper getFollowersByName(Weibo weibo, String screen_name, Integer count)
			throws WeiboException {
		return User.constructWapperUsers(weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "friendships/followers.json",
				new PostParameter[] {
						new PostParameter("screen_name", screen_name),
						new PostParameter("count", count.toString()) }));
	}

	/**
	 * @see <a
	 *      href="http://api.weibo.com/2/friendships/show.json">friendships/show</a>
	 * @since JDK 1.5
	 */
	public EachOtherRelationShip showFriendshipsById(Weibo weibo, String source_id,
			String target_id) throws WeiboException {
		return new EachOtherRelationShip(weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "friendships/show.json",
				new PostParameter[] {
						new PostParameter("source_id", source_id),
						new PostParameter("target_id", target_id) })
				.asJSONObject());
	}
}
